import request from '@/utils/request'


// 获取角色管理分页列表
export const getRolePageList = (page, limit, roleName) => {
  return request.get(`/admin/acl/role/${page}/${limit}`, {
    params: roleName
  })
}


// 添加角色
export const saveRole = (role) => {
  return request.post(`/admin/acl/role/save`, role)
}



// 修改角色
export const updateRoleApi = (role) => {
  return request.put(`/admin/acl/role/update`, role)
}



// 根据id删除单个角色
export const deleteRoleById = (id) => {
  return request.delete(`/admin/acl/role/remove/${id}`,)
}



// 根据id列表批量删除角色
export const removeRole = (ids) => {
  return request.delete(`/admin/acl/role/batchRemove`, {
    data: ids
  })
}


// 根据角色id查询菜单
export const getperList = (roleId) => {
  return request.get(`/admin/acl/permission/toAssign/${roleId}`)
}


// 给用户分配角色
export const doAssignApi = (roleId, permissionId) => {
  return request.post(`/admin/acl/permission/doAssign`, null, {
    params: {
      roleId: roleId,
      permissionId: permissionId.join()
    }
  })
}
